#include<bits/stdc++.h>
using namespace std;
long long t,n,m,l,v,p[100005],pos=0,sum=0,last,lp,rp,mid,ans,sans;
struct car {
    long long d,v,a;
}c[100005];
struct node{
    long long l,r;
    bool operator<(const node x)const {
        if (r==x.r) return l<x.l;
        return r<x.r;
    }
}s[100005];
int main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%lld",&t);
    while (t--) {
        pos=sum=last=0;
        scanf("%lld%lld%lld%lld",&n,&m,&l,&v);
        for (long long i=1;i<=n;i++) scanf("%lld%lld%lld",&c[i].d,&c[i].v,&c[i].a);
        for (long long i=1;i<=m;i++) scanf("%lld",&p[i]);
        for (long long i=1;i<=n;i++) {
            if (c[i].v>v) {
                if (c[i].a>=0) {
                    lp=1,rp=m,ans=m+1;
                    while (lp<=rp) {
                        mid=lp+rp>>1;
                        if (p[mid]>=c[i].d) {
                            ans=mid;
                            rp=mid-1;
                        }
                        else lp=mid+1;
                    }
                    if (ans<=m) s[++pos]={ans,m};
                }
                else {
                    lp=1,rp=m,ans=0;
                    while (lp<=rp) {
                        mid=lp+rp>>1;
                        if (p[mid]>=c[i].d) {
                            ans=mid;
                            rp=mid-1;
                        }
                        else lp=mid+1;
                    }
                    lp=ans,rp=m,sans=-1;
                    while (lp<=rp) {
                        mid=lp+rp>>1;
                        if (c[i].v*c[i].v+c[i].a*(p[mid]-c[i].d)*2>v*v&&c[i].v-c[i].a*(p[mid]-c[i].d)>=0) {
                            sans=mid;
                            lp=mid+1;
                        }
                        else rp=mid-1;
                    }
                    if (ans<=sans) s[++pos]={ans,sans};
                }
            }
            else if (c[i].a>0) {
                lp=1,rp=m,sans=m+1;
                while (lp<=rp) {
                    mid=lp+rp>>1;
                    if (c[i].v*c[i].v+c[i].a*(p[mid]-c[i].d)*2>v*v) {
                        sans=mid;
                        rp=mid-1;
                    }
                    else lp=mid+1;
                }
                if (sans<=m) s[++pos]={sans,m};
            }
        }
        sort(s+1,s+pos+1);
        for (long long i=1;i<=pos;i++) {
            if (s[i].l<=last) continue;
            sum++;
            last=s[i].r;
        }
        printf("%lld %lld\n",pos,m-sum);
    }
    return 0;
}